<script type="text/javascript">
  arSysVars = new Array();
  fltSVS = new iseFilter("fltSVS", FLT_OBJ_TYP_VARS);
  lastDir = 1;
  var sortBy = 'name';
  var bSecondary = false;
  var bShowAll = false;
  <%
    if( system.GetVar("iSecondary") == 1 )
    {
      Write( 'bSecondary = true;' );
    }
    
    if (system.GetVar("iShowAll") == 1 )
    {
      Write( 'bShowAll = true;' );
    }
  %>
    
  DivSort = function(colName)
  { 
    sortBy = colName;
    arSysVars = new Array();
    SetSelectedStyle(colName);  
    if (!bShowAll)
    {
      new sysVarsPopupLoader('/pages/msg/sysVarsArray.htm',colName,bSecondary);
    }
    else
    {
      new sysVarsPopupLoader('/pages/msg/sysVarsArrayAll.htm',colName,bSecondary);
    }
  }
  SetSelectedStyle = function(colName)
  {
    // reset all SortSelected columns
    var ths = document.getElementById("svsBody").getElementsByTagName("th");
    for(th in ths)
    { 
      if(ths[th].innerHTML)
      {
        ths[th].innerHTML = ths[th].innerHTML.replace(/pt11 SortSelected/g,"pt11 Sort");
      }
    }
    var selTbHeader = document.getElementById(colName);
    if(selTbHeader)
    {
      selTbHeader.className = selTbHeader.className.replace(/pt11 Sort/, "pt11 SortSelected");
    }
  }
  ClearSysVarsTable = function()
  {
    var tableBody = document.getElementById("sysVarDisplay");
    var count = tableBody.rows.length-1;
    for(var x=count; x > -1; x--)
    {
      tableBody.deleteRow(x);
    }
  }
  DivSort(sortBy);
  
  toggleInternal = function()
  {
    bShowAll = !bShowAll;
    jQuery("#internalToggleButton").text( bShowAll === true ? translateKey('footerBtnHideInternalSystemVars') : translateKey('footerBtnShowInternalSystemVars'));
    if (lastDir === 1) { lastDir = 0; } else { lastDir = 1;}
    DivSort(sortBy);
  }
</script>
<div class="popupTitle" id="divTitle">
  &nbsp;&nbsp;
  <% 
  Write(system.GetVar("title"));
  %>
</div>
<div class="CLASS00300">
  <table class="popupTableScript CLASS00301" cellpadding="0" >
    <colgroup>
      <col style="width: 10%;"/>
      <col style="width: 50%;"/>
      <col style="width: 5%;"/>
      <col style="width: 30%;"/>
      <col style="width: 5%;"/>
    </colgroup>
    <thead id="svsBody">
    <tr id="rowhead">
      <%string sCssName="Sort"; if(system.GetSessionVar("sessionLS")=="name"){sCssName="SortSelected";} %>
      <th class="CLASS00302"><div id="name" class="pt11 <%Write(sCssName); %>" onclick="DivSort('name');">${thName}</div></th>
      <th class="CLASS00302">${thDescription}</th>
      <%string sCssName="Sort"; if(system.GetSessionVar("sessionLS")=="typenames"){sCssName="SortSelected";} %>
      <th class="CLASS00302"><div id="typenames" class="pt11 <%Write(sCssName); %>" onclick="DivSort('typenames');">${thTypeOfVariable}</div></th>
      <th class="CLASS00302">${thValues}</th>
      <%string sCssName="Sort"; if(system.GetSessionVar("sessionLS")=="unit"){sCssName="SortSelected";} %>
      <th class="CLASS00302"><div id="unit" class="pt11 <%Write(sCssName); %>" onclick="DivSort('unit');">${thUnit}</div></th>
    </tr>
    
    <tr id="rowflt">
      <td class="CLASS00303">
        <div id="btnFilterName" class="FilterBtn">${thFilter}</div>
        <div class="FilterSubMenu" id="btnFilterNameSub" style="display:none;">
            <input id="ftName" onkeypress="iseSFilterCheckEnterEsc(event.keyCode, 'ftSetNameBtn', 'ftCancelNameBtn')" type="text" size="15" class="CLASS00305"/>
            <div id="ftSetNameBtn" class='FilterSetButton CLASS00306' onclick="setSFilter(fltSVS, 'ftName', FIL_NAME);updateTable();$('btnFilterNameSub').hide();" >${filterSet}</div>
            <div id="ftCancelNameBtn" class='FilterSetButton' onclick="$('btnFilterNameSub').hide();">${filterClose}</div>
        </div>
      </td>
      <td class="CLASS00307"></td>
      <td class="CLASS00308">
        <div id="btnFilterVarType" class="FilterBtn">${thFilter}</div>
        <div class="FilterSubMenu" id="btnFilterVarTypeSub" style="display:none;">
            <table class="CLASS00309">
              <tr>
                <td>${lblLogicValue}</td>
                <td><input type="checkbox" id="cbLogic" /></td>
              </tr>
              <tr>
                <td>${lblValueList}</td>
                <td><input type="checkbox" id="cbValueList" /></td>
              </tr>
              <tr>
                <td>${lblNumber}</td>
                <td><input type="checkbox" id="cbNumber" /></td>
              </tr>
              <tr>
                <td>${lblAlarm}</td>
                <td><input type="checkbox" id="cbAlarm" /></td>
              </tr>
              <tr>
                <td>${lblString}</td>
                <td><input type="checkbox" id="cbString" /></td>
              </tr>
            </table>
            <div class='FilterSetButton' onclick='setAFilter(fltSVS, "vartypes");updateTable();$("btnFilterVarTypeSub").hide();'>${filterSet}</div>
            <div class='FilterSetButton' onclick="$('btnFilterVarTypeSub').hide();">${filterClose}</div>
        </div>
      </td>
      <td class="CLASS00310"></td>
      <td class="CLASS00311">
        <div id="btnFilterUnit" class="FilterBtn">${thFilter}</div>
        <div class="FilterSubMenu" id="btnFilterUnitSub" style="display:none;">
            <input id="ftUnit" onkeypress="iseSFilterCheckEnterEsc(event.keyCode, 'ftSetUnitBtn','ftCancelUnitBtn')" type="text" size="15" class="CLASS00305" />
            <div id="ftSetUnitBtn" class="FilterSetButton CLASS00306" onclick="setSFilter(fltSVS, 'ftUnit', FIL_UNIT);updateTable();$('btnFilterUnitSub').hide();" >${filterSet}</div>
            <div id="ftCancelUnitBtn" class='FilterSetButton' onclick="$('btnFilterUnitSub').hide();">${filterClose}</div>
        </div>
      </td>
    </tr>
   </thead>
   <tbody id="sysVarDisplay">
   </tbody>
  </table>
</div>
<div class="CLASS00312">
        <table>
        <tr>
          <% string sCancelClick = "PopupClose();"; if( system.GetVar("iSecondary") == "1" ) { sCancelClick = "restorePrevious();"; } %>
          <td><div class="FooterButton CLASS00313" onclick="<% Write(sCancelClick); %>" >${footerBtnCancel}</div></td>
          <td><div class="FooterButton CLASS00314" onclick="fltSVS.clearFilters();updateTable();">${footerBtnResetFilter}</div></td>
          <td><div id="internalToggleButton" class="FooterButton CLASS00314 CLASS04905" onclick="fltSVS.clearFilters();toggleInternal();updateTable();">${footerBtnShowInternalSystemVars}</div></td>
        </tr>
        </table>
</div>

<script type="text/javascript">
  var mouseOpts = {
    onTopOver: function(divToShow) {
      selectFilters(fltSVS, divToShow);
    }
  };
  new iseSubMenuControl("btnFilterName", "btnFilterNameSub", "svsBody", {d: 2},  mouseOpts, true, true);
  new iseSubMenuControl("btnFilterVarType", "btnFilterVarTypeSub", "svsBody", {d: 2}, mouseOpts, true, true);  
  new iseSubMenuControl("btnFilterUnit", "btnFilterUnitSub", "svsBody", {d: 2}, mouseOpts, true, true);

  jQuery("#btnFilterName").click(function(){
    jQuery("#ftName").focus();
  });

  jQuery("#btnFilterUnit").click(function(){
    jQuery("#ftUnit").focus();
  });

  updateTable = function() {
    for (var i = 0; i < arSysVars.length; i++) {
      if (fltSVS.objPassFilter(arSysVars[i])) {
        show(arSysVars[i]['trid']);
      }
      else {
        hide(arSysVars[i]['trid']);
      }
    }
  }
  
  if (NAV_IE && (arSysVars.length == 0))
  {
     show("fltSpacer");
  }
</script>
